package com.kaishengit.service;

import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.kaishengit.core.service.BaseService;
import com.kaishengit.pojo.Company;
import com.kaishengit.pojo.Contact;
import com.kaishengit.pojo.Employee;
import com.kaishengit.pojo.Product;
import com.kaishengit.util.GetNow;

@Service
@Transactional
public class ContactService extends BaseService{
 
     private  List<Contact> contactList;


	/*@SuppressWarnings("static-access")
	public void save(Contact co,Employee e) {
		//co.setId(new GetUUID().getUUID());
		co.setCreatetime(new GetNow().getNow());
	}*/

	public void save(Contact co,Employee e, Product product, Company c) {
		c.setCompanyname(co.getCompanyname());
		c.setTel(co.getTel());
		c.setEmail(co.getEmail());
		c.setIm(co.getIm());
		c.setWebsite(co.getWebsite());
		c.setAddress(co.getAddress());
		c.setMessage(co.getMessage());
		c.setEmployee(e);
		c.setProduct(product);
		getCompanyDao().save(c);

		
		System.out.println("cccc:  "  + c.getId());
		
		co.setCreatetime(GetNow.getNow());
		co.setEmployee(e);
		co.setProduct(product);
		co.setCompany(c);
		
		getContactDao().save(co);
		
	}


	public void save() {
		
	}

	public List<Contact> findAll() {
		
		return contactList = getContactDao().findAll();
		
	}


	//get,set;
	
	public List<Contact> getContactList() {
		return contactList;
	}

	public void setContactList(List<Contact> contactList) {
		this.contactList = contactList;
	}

	public Contact findByName(String contactname) {
		
		return getContactDao().findByName(contactname);
	}


	public List<Contact> findAllContact(Employee e, Product p) {
		return getContactDao().findAllContact(e,p);
	}

}
